@extends('admin.layout.base')

@section('main')
    <h1 class="page-header">编辑配置 {{ $config->name }}</h1>
    @if (count($errors) > 0)
        <div class="alert alert-danger">
            <strong>糟糕!</strong> 发生以下错误<br><br>
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif
    <form action="{{ route('admin.configs.update', $config->id) }}" method="post">
        <div class="col-md-9">

            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <input type="hidden" name="_method" value="PATCH">

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>名称</label>
                        <input type="text" class="form-control" name="name"
                               value="{{ $config->name }}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>AppStore ID</label>
                        <input type="text" class="form-control" name="res_id"
                               value="{{ $config->res_id }}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>Banner ID</label>
                        <input type="text" class="form-control" name="banner_id"
                               value="{{ $config->banner_id }}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>插屏ID</label>
                        <input type="text" class="form-control" name="interstitial_id"
                               value="{{ $config->interstitial_id }}">
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label>标题</label>
                        <input type="text" class="form-control" name="alert_title"
                               value="{{ $config->alert_title }}">
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="form-group">
                        <label>延时</label>
                        <input type="number" class="form-control" name="alert_delay"
                               value="{{ $config->alert_delay }}">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label>内容</label>
                <textarea class="form-control" name="alert_message">{{ $config->alert_message }}</textarea>
            </div>
            <div class="form-group">
                <label>跳转地址</label>
                <input type="url" class="form-control" name="alert_url"
                       value="{{ $config->alert_url }}">
            </div>
        </div>
        <div class="col-md-3">
            <div class="panel panel-default">
                <div class="panel-heading">保存</div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="checkbox checkbox-success">
                            <input id="check" type="checkbox" name="check" value="1"
                                   @if($config->check) checked @endif >
                            <label for="check">
                                骗审
                            </label>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="checkbox checkbox-success">
                            <input id="rate" type="checkbox" name="rate" value="1" @if($config->rate) checked @endif >
                            <label for="rate">
                                骗赞
                            </label>
                        </div>
                    </div>
                </div>
                <div class="panel-footer">
                    <button type="submit" class="btn btn-primary">更新配置</button>
                </div>
            </div>
        </div>
    </form>
@stop